/*
 * @文件描述:
 * @版本:
 * @作者:周晨阳
 * @Date:2021-11-20 16:21:46
 */
#include "Task.h"
#include "MuscleControl.h"
#include "stdio.h"

DWORD WINAPI userInput(LPVOID lpParamter)
{
    char i;
    while (1)
    {
        /* code */
        printf("input you command:");
        scanf_s("%c", &i);
        printf("\nyour command:%c", i);
        switch (i)
        {
        case 'o':
            /* code */
            MC_On();
            break;
        case 'f':
            /* code */
            MC_Off();
            break;
        case 'i':
            /* code */
            MC_increaseStrength();
            break;
        case 'd':
            /* code */
            MC_decreaseStrength();
            break;
        case 'e':
            /* code */
            MC_execute();
            break;
        case 's':
            /* code */
            MC_stop();
            break; 
        case 'r':
            /* code */
            MC_reset();
            break;

        default:
            break;
        }
        Sleep(10);
    }
}
void observer(MUSCLE_CONTROL_STATE s)
{
    switch (s)
    {
    case MUSCLE_CONTROL_STATE_ON:
        printf("\nON\n");
        break;
    case MUSCLE_CONTROL_STATE_OFF:
        printf("\nOff\n");
        break;
    case MUSCLE_CONTROL_STATE_EXECUTING:
        printf("\nEXECUTING\n");
        break;
    case MUSCLE_CONTROL_STATE_IDLE:
        printf("\nIDLE\n");
        break;
    case MUSCLE_CONTROL_STATE_RESETTING:
        printf("\nRESETTING\n");
        break;
    case MUSCLE_CONTROL_STATE_CHANGING:
        printf("\nCHANGING\n");
        break;

    default:
        break;
    }
}
void execute(void)
{
    HANDLE hThread = CreateThread(NULL, 0, userInput, NULL, 0, NULL);
    //CloseHandle(hThread);

    MC_setObserver(observer);
    // MC_On();
    // MC_increaseStrength();
    // MC_increaseStrength();

    // MC_increaseStrength();

    // MC_execute();
    // Sleep(2000);
    // MC_reset();
    // MC_Off();
    WaitForSingleObject(hThread, INFINITE);
}